/*
 * HashingView.java
 */

package hashing;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import org.jdesktop.application.TaskMonitor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import java.util.Enumeration;
import javax.swing.JRadioButton;


/**
 * The application's main frame.
 */
public class HashingView extends FrameView {
    
    public String caminhoArquivo1 = "";
    public String caminhoArquivo2 = "";
    public int d,k;
    
    
    public HashingView(SingleFrameApplication app) {
        super(app);

        initComponents();

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                //statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                //statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        //statusAnimationLabel.setIcon(idleIcon);
        //progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        //statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    //progressBar.setVisible(true);
                    //progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    //statusAnimationLabel.setIcon(idleIcon);
                    //progressBar.setVisible(false);
                    //progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String)(evt.getNewValue());
                    //statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer)(evt.getNewValue());
                    //progressBar.setVisible(true);
                    //progressBar.setIndeterminate(false);
                    //progressBar.setValue(value);
                }
            }
        });
    }

    @Action
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jRadioButton3 = new javax.swing.JRadioButton();
        jRadioButton4 = new javax.swing.JRadioButton();
        jRadioButton5 = new javax.swing.JRadioButton();
        jLabel3 = new javax.swing.JLabel();
        jSpinner1 = new javax.swing.JSpinner();
        jButton1 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        canvas1 = new java.awt.Canvas();
        jLabel9 = new javax.swing.JLabel();
        canvas2 = new java.awt.Canvas();
        jRadioButtonGorilla1 = new javax.swing.JRadioButton();
        jRadioButton7 = new javax.swing.JRadioButton();
        jRadioButton8 = new javax.swing.JRadioButton();
        jRadioButton9 = new javax.swing.JRadioButton();
        jRadioButton10 = new javax.swing.JRadioButton();
        jLabel10 = new javax.swing.JLabel();
        jRadioButton11 = new javax.swing.JRadioButton();
        jRadioButton12 = new javax.swing.JRadioButton();
        jRadioButton13 = new javax.swing.JRadioButton();
        jRadioButton14 = new javax.swing.JRadioButton();
        jRadioButton15 = new javax.swing.JRadioButton();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();

        mainPanel.setName("mainPanel"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(hashing.HashingApp.class).getContext().getResourceMap(HashingView.class);
        jLabel1.setText(resourceMap.getString("lbEscolha.text")); // NOI18N
        jLabel1.setName("lbEscolha"); // NOI18N

        jLabel2.setText(resourceMap.getString("lbTamanho.text")); // NOI18N
        jLabel2.setName("lbTamanho"); // NOI18N

        buttonGroup3.add(jRadioButton1);
        jRadioButton1.setText(resourceMap.getString("jRadioButton1.text")); // NOI18N
        jRadioButton1.setName("jRadioButton1"); // NOI18N
        jRadioButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton1MouseClicked(evt);
            }
        });

        buttonGroup3.add(jRadioButton2);
        jRadioButton2.setText(resourceMap.getString("jRadioButton2.text")); // NOI18N
        jRadioButton2.setName("jRadioButton2"); // NOI18N
        jRadioButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton2MouseClicked(evt);
            }
        });

        buttonGroup3.add(jRadioButton3);
        jRadioButton3.setText(resourceMap.getString("jRadioButton3.text")); // NOI18N
        jRadioButton3.setName("jRadioButton3"); // NOI18N
        jRadioButton3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton3MouseClicked(evt);
            }
        });

        buttonGroup3.add(jRadioButton4);
        jRadioButton4.setText(resourceMap.getString("jRadioButton4.text")); // NOI18N
        jRadioButton4.setName("jRadioButton4"); // NOI18N
        jRadioButton4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton4MouseClicked(evt);
            }
        });

        buttonGroup3.add(jRadioButton5);
        jRadioButton5.setText(resourceMap.getString("jRadioButton5.text")); // NOI18N
        jRadioButton5.setName("jRadioButton5"); // NOI18N
        jRadioButton5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton5MouseClicked(evt);
            }
        });

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jSpinner1.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1)));
        jSpinner1.setName("jSpinner1"); // NOI18N

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        canvas1.setName("canvas1"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        canvas2.setName("canvas2"); // NOI18N

        buttonGroup1.add(jRadioButtonGorilla1);
        jRadioButtonGorilla1.setText(resourceMap.getString("jRadioButtonGorilla1.text")); // NOI18N
        jRadioButtonGorilla1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jRadioButtonGorilla1.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jRadioButtonGorilla1.setName("jRadioButtonGorilla1"); // NOI18N
        jRadioButtonGorilla1.setOpaque(false);
        jRadioButtonGorilla1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButtonGorilla1MouseClicked(evt);
            }
        });

        buttonGroup1.add(jRadioButton7);
        jRadioButton7.setText(resourceMap.getString("jRadioButton7.text")); // NOI18N
        jRadioButton7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jRadioButton7.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jRadioButton7.setName("jRadioButton7"); // NOI18N
        jRadioButton7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton7MouseClicked(evt);
            }
        });

        buttonGroup1.add(jRadioButton8);
        jRadioButton8.setText(resourceMap.getString("jRadioButton8.text")); // NOI18N
        jRadioButton8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jRadioButton8.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jRadioButton8.setName("jRadioButton8"); // NOI18N
        jRadioButton8.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton8MouseClicked(evt);
            }
        });

        buttonGroup1.add(jRadioButton9);
        jRadioButton9.setText(resourceMap.getString("jRadioButton9.text")); // NOI18N
        jRadioButton9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jRadioButton9.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jRadioButton9.setName("jRadioButton9"); // NOI18N
        jRadioButton9.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton9MouseClicked(evt);
            }
        });

        buttonGroup1.add(jRadioButton10);
        jRadioButton10.setText(resourceMap.getString("jRadioButton10.text")); // NOI18N
        jRadioButton10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jRadioButton10.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        jRadioButton10.setName("jRadioButton10"); // NOI18N
        jRadioButton10.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton10MouseClicked(evt);
            }
        });

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        buttonGroup2.add(jRadioButton11);
        jRadioButton11.setText(resourceMap.getString("jRadioButton11.text")); // NOI18N
        jRadioButton11.setName("jRadioButton11"); // NOI18N
        jRadioButton11.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton11MouseClicked(evt);
            }
        });

        buttonGroup2.add(jRadioButton12);
        jRadioButton12.setText(resourceMap.getString("jRadioButton12.text")); // NOI18N
        jRadioButton12.setName("jRadioButton12"); // NOI18N
        jRadioButton12.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton12MouseClicked(evt);
            }
        });

        buttonGroup2.add(jRadioButton13);
        jRadioButton13.setText(resourceMap.getString("jRadioButton13.text")); // NOI18N
        jRadioButton13.setName("jRadioButton13"); // NOI18N
        jRadioButton13.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton13MouseClicked(evt);
            }
        });

        buttonGroup2.add(jRadioButton14);
        jRadioButton14.setText(resourceMap.getString("jRadioButton14.text")); // NOI18N
        jRadioButton14.setName("jRadioButton14"); // NOI18N
        jRadioButton14.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton14MouseClicked(evt);
            }
        });

        buttonGroup2.add(jRadioButton15);
        jRadioButton15.setText(resourceMap.getString("jRadioButton15.text")); // NOI18N
        jRadioButton15.setName("jRadioButton15"); // NOI18N
        jRadioButton15.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jRadioButton15MouseClicked(evt);
            }
        });

        jSeparator1.setName("jSeparator1"); // NOI18N

        jSeparator2.setName("jSeparator2"); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7))
                    .addComponent(jLabel8)
                    .addComponent(canvas1, javax.swing.GroupLayout.PREFERRED_SIZE, 1000, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(canvas2, javax.swing.GroupLayout.PREFERRED_SIZE, 1000, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addComponent(jRadioButton11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jRadioButton12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jRadioButton13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jRadioButton14))
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addComponent(jRadioButtonGorilla1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jRadioButton7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jRadioButton8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jRadioButton9)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jRadioButton10)
                            .addComponent(jRadioButton15)))
                    .addComponent(jLabel10)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addComponent(jRadioButton1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jRadioButton2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jRadioButton3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jRadioButton4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jRadioButton5))
                            .addComponent(jLabel2))
                        .addGap(18, 18, 18)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)))
                    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 526, Short.MAX_VALUE)))
                .addContainerGap(33, Short.MAX_VALUE))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButtonGorilla1)
                    .addComponent(jRadioButton7)
                    .addComponent(jRadioButton8)
                    .addComponent(jRadioButton9)
                    .addComponent(jRadioButton10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButton11)
                    .addComponent(jRadioButton12)
                    .addComponent(jRadioButton13)
                    .addComponent(jRadioButton14)
                    .addComponent(jRadioButton15))
                .addGap(18, 18, 18)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jRadioButton1)
                            .addComponent(jRadioButton2)
                            .addComponent(jRadioButton3)
                            .addComponent(jRadioButton4)
                            .addComponent(jRadioButton5)
                            .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(11, 11, 11))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(44, 44, 44)))
                .addGap(7, 7, 7)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7))
                .addGap(18, 18, 18)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(canvas1, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(22, 22, 22)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(canvas2, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(106, 106, 106))
        );

        jRadioButton11.getAccessibleContext().setAccessibleName(resourceMap.getString("jRadioButton11.AccessibleContext.accessibleName")); // NOI18N
        jRadioButton11.getAccessibleContext().setAccessibleDescription(resourceMap.getString("jRadioButton11.AccessibleContext.accessibleDescription")); // NOI18N
        jRadioButton12.getAccessibleContext().setAccessibleName(resourceMap.getString("jRadioButton12.AccessibleContext.accessibleName")); // NOI18N
        jRadioButton13.getAccessibleContext().setAccessibleName(resourceMap.getString("jRadioButton13.AccessibleContext.accessibleName")); // NOI18N
        jRadioButton14.getAccessibleContext().setAccessibleName(resourceMap.getString("jRadioButton14.AccessibleContext.accessibleName")); // NOI18N
        jRadioButton15.getAccessibleContext().setAccessibleName(resourceMap.getString("jRadioButton15.AccessibleContext.accessibleName")); // NOI18N

        setComponent(mainPanel);
    }// </editor-fold>//GEN-END:initComponents

private void jRadioButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton1MouseClicked
// TODO add your handling code here:
    this.d = Integer.parseInt(jRadioButton1.getLabel());
}//GEN-LAST:event_jRadioButton1MouseClicked

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
// TODO add your handling code here:
    int i,vetorP[],vetorQ[],PQ;
    double normaP,normaQ,cos;
    BKDRHash bkdr = new BKDRHash();
    String str = new String();
    
    vetorP = new int[d];
    vetorQ = new int[d];
    
    this.k = Integer.parseInt(jSpinner1.getValue().toString());
    
    for (Enumeration e=buttonGroup1.getElements(); e.hasMoreElements(); ) {
        JRadioButton b = (JRadioButton)e.nextElement();
        if (b.getModel() == buttonGroup1.getSelection()) {
            caminhoArquivo1 = b.getLabel()+"_HbB_FASTAs.in";
            jLabel8.setText(b.getLabel());
        }
    }
    for (Enumeration e=buttonGroup2.getElements(); e.hasMoreElements(); ) {
        JRadioButton b = (JRadioButton)e.nextElement();
        if (b.getModel() == buttonGroup2.getSelection()) {
            caminhoArquivo2 = b.getLabel()+"_HbB_FASTAs.in";
            jLabel9.setText(b.getLabel());
        }
    }
    for (Enumeration e=buttonGroup3.getElements(); e.hasMoreElements(); ) {
        JRadioButton b = (JRadioButton)e.nextElement();
        if (b.getModel() == buttonGroup3.getSelection()) {
            d = Integer.parseInt(b.getLabel());
        }
    }
    if(k>d)
    {
        JOptionPane.showMessageDialog(null,"Tamanho de K inválido");
        return;
    }
   
    
    /* Lê o primeiro arquivo, usa a função de hashing e o monta o profile no vetorP */
    Arquivo a = new Arquivo();    
    a.le_txt(caminhoArquivo1);
    str = a.fasta;
    //str == string completa
    //str2 == k-gram comecando em i e terminando em i+k
    for(i=0;i<str.length()-k;i++){
        char str2[] = str.substring(i, i+k).toCharArray();
        int chave = (int)(bkdr.Hash(str2, k)%d);
        if(chave<0 || chave > d)
            continue;
        vetorP[chave]+=1;
    }

    Desenha(vetorP,canvas1);//Desenha o profile do primeiro animal
    
    /* Lê o segundo arquivo, usa a função de hashing e o monta o profile no vetorQ */
    Arquivo b = new Arquivo();
    b.le_txt(caminhoArquivo2);
    str = b.fasta;
    //str == string completa
    //str2 == k-gram comecando em i e terminando em i+k
    for(i=0;i<str.length()-k;i++){
        char str2[] = str.substring(i, i+k).toCharArray();
        int chave = (int)(bkdr.Hash(str2, k)%d);
        if(chave<0 || chave > d)
            continue;
        vetorQ[chave]+=1;
    }

    Desenha(vetorQ,canvas2);//Desenha o profile do segundo animal
    
    /* Calcula o índice de similaridade */
    PQ=0;
    normaP=normaQ=0;
    for(i=0;i<d;i++){
        PQ+=vetorP[i]*vetorQ[i];
        normaP+=vetorP[i]*vetorP[i];
        normaQ+=vetorQ[i]*vetorQ[i];
    }
    normaP = Math.sqrt(normaP);
    normaQ = Math.sqrt(normaQ);
    cos = PQ / (normaP*normaQ);
    jLabel7.setText(""+cos);
    
    return;
}//GEN-LAST:event_jButton1MouseClicked

private void jRadioButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton2MouseClicked
// TODO add your handling code here:
    this.d = Integer.parseInt(jRadioButton2.getLabel());
}//GEN-LAST:event_jRadioButton2MouseClicked

private void jRadioButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton3MouseClicked
// TODO add your handling code here:
    this.d = Integer.parseInt(jRadioButton3.getLabel());
}//GEN-LAST:event_jRadioButton3MouseClicked

private void jRadioButton4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton4MouseClicked
// TODO add your handling code here:
    this.d = Integer.parseInt(jRadioButton4.getLabel());
}//GEN-LAST:event_jRadioButton4MouseClicked

private void jRadioButton5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton5MouseClicked
// TODO add your handling code here:
    this.d = Integer.parseInt(jRadioButton5.getLabel());
}//GEN-LAST:event_jRadioButton5MouseClicked

private void jRadioButtonGorilla1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButtonGorilla1MouseClicked
    this.caminhoArquivo1 = "Gorilla_HbB_FASTAs.in";
}//GEN-LAST:event_jRadioButtonGorilla1MouseClicked

private void jRadioButton7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton7MouseClicked
    this.caminhoArquivo1 = "Horse_HbB_FASTAs.in";
}//GEN-LAST:event_jRadioButton7MouseClicked

private void jRadioButton8MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton8MouseClicked
    this.caminhoArquivo1 = "Rockcod_HbB_FASTAs.in";
}//GEN-LAST:event_jRadioButton8MouseClicked

private void jRadioButton9MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton9MouseClicked
    this.caminhoArquivo1 = "SeaCucumber_HbB_FASTAs.in";
}//GEN-LAST:event_jRadioButton9MouseClicked

private void jRadioButton10MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton10MouseClicked
    this.caminhoArquivo1 = "SpiderMonkey_HbB_FASTAs.in";
}//GEN-LAST:event_jRadioButton10MouseClicked

private void jRadioButton11MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton11MouseClicked
    this.caminhoArquivo2 = "Gorilla_HbB_FASTAs.in";
}//GEN-LAST:event_jRadioButton11MouseClicked

private void jRadioButton12MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton12MouseClicked
    this.caminhoArquivo2 = "Horse_HbB_FASTAs.in";
}//GEN-LAST:event_jRadioButton12MouseClicked

private void jRadioButton13MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton13MouseClicked
    this.caminhoArquivo2 = "Rockcod_HbB_FASTAs.in";
}//GEN-LAST:event_jRadioButton13MouseClicked

private void jRadioButton14MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton14MouseClicked
    this.caminhoArquivo2 = "SeaCucumber_HbB_FASTAs.in";
}//GEN-LAST:event_jRadioButton14MouseClicked

private void jRadioButton15MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jRadioButton15MouseClicked
    this.caminhoArquivo2 = "SpiderMonkey_HbB_FASTAs.in";
}//GEN-LAST:event_jRadioButton15MouseClicked
private void Desenha(int profile[], Canvas c){
    
    Graphics g = c.getGraphics();
    g.clearRect(0, 0, 1000, 50);

        Graphics2D g2 = (Graphics2D) g.create();
        Rectangle2D rect = new Rectangle2D.Float();
        float largura=0;
        switch(d)
        {
            case 200:
            {
                largura=5;
                break;
            }
            case 400:
            {
                largura=(float) 2.5;
                break;
            }
            case 600:
            {
                largura = (float)1.6;
                break;
            }
            case 800:
            {
                largura = (float)1.25;
                break;
            }
            case 1000:
                largura = 1;
                break;
        }       
        int i,j=0;
        Color Pigment;
        for(i=0;i<d;i++){
                rect.setRect(j, 0,largura, 50);
                //int t = profile[i];
                Pigment = new Color (255-profile[i]*8, 255-profile[i]*8, 255-profile[i]*8);
                g2.setColor(Pigment);
                g2.fill(rect);                
                j+=largura;
        }
        c.setVisible(true);
            
}
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private java.awt.Canvas canvas1;
    private java.awt.Canvas canvas2;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton10;
    private javax.swing.JRadioButton jRadioButton11;
    private javax.swing.JRadioButton jRadioButton12;
    private javax.swing.JRadioButton jRadioButton13;
    private javax.swing.JRadioButton jRadioButton14;
    private javax.swing.JRadioButton jRadioButton15;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JRadioButton jRadioButton3;
    private javax.swing.JRadioButton jRadioButton4;
    private javax.swing.JRadioButton jRadioButton5;
    private javax.swing.JRadioButton jRadioButton7;
    private javax.swing.JRadioButton jRadioButton8;
    private javax.swing.JRadioButton jRadioButton9;
    private javax.swing.JRadioButton jRadioButtonGorilla1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSpinner jSpinner1;
    private javax.swing.JPanel mainPanel;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;
}